use std::{env, fs, path};
use std::fmt::format;
use std::path::PathBuf;

fn main() {
    let mut current_dir = env::current_dir().unwrap();
    current_dir = current_dir.join("design").join("src");
    println!("Path: {:?}:", current_dir);
    walk_dir(current_dir, true, asd)
}

fn asd() {}

fn walk_dir(dir: PathBuf, child: bool, handle: fn()) {
    for entry in fs::read_dir(dir).unwrap() {
        let entry = entry.unwrap();
        if entry.path().is_dir() {
            let path_buf = entry.path().join("mod.rs");
            let x = path_buf.parent().unwrap();
            let x1 = x.to_str().unwrap();
            let option = x1.split("/").last().unwrap();
            println!("parent {:?}", option);
            let path_buf = entry.path().join("mod.rs");
            fs::write(path_buf, format!("pub mod {:};", option)).unwrap();

            walk_dir(entry.path(), true, handle)
        }
    }
}